<template>
  <div>

    <el-table :data="news.result">
      <el-table-column label="新闻图片" prop="m_img" width="120px" align="center">
        <template slot-scope="scope">
        <img :src="scope.row.n_img" alt="" width="60px" height="40px">
      </template> 
      </el-table-column>
      <el-table-column label="新闻标题" prop="n_title" align="center"></el-table-column>
      <el-table-column label="新闻详情" prop="n_details" width="120px" align="center" show-overflow-tooltip></el-table-column>
      <el-table-column label="发表时间" prop="n_time" align="center"></el-table-column>
      <el-table-column label="操作" width="180px" align="center">
        <template slot-scope="scope">
          <el-button size="small" type="success" icon="el-icon-check" circle></el-button>
        <el-button size="small" type="info" icon="el-icon-message" circle></el-button>
        <el-button
        @click="$router.push('/home/hospital-update/'+scope.row.h_id)"
        size="small" type="warning" icon="el-icon-edit" circle></el-button>
        <el-button
        @click="deleteItem(scope.row)"
         size="small" type="danger" icon="el-icon-delete" circle></el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination
    @current-change="changeCurrentPage"
     style="margin:10px"
     layout="->,total,prev,pager,next,slot,jumper"
     :total="news.total"
     :page-size="news.pagesize"
     :current-page="news.page"
     background></el-pagination>
  </div>
</template>

<script>
import httpApi from '@/http';
  export default {
    data() {
      return {
        news:{
          page:1, // 当前页码
          pagesize:3, // 每页多少条
          total:0, // 总条目数
          result:[], // 新闻数据
        }
      }
    },
    methods: {
      queryAll(){
        httpApi.newApi.queryAll({page:this.news.page,pagesize:this.news.pagesize}).then(res =>{
          console.log('新闻',res);
          this.news = res.data.data
        })
      },
      changeCurrentPage(page){
      console.log(page);
      this.news.page = page // 修改当前页
 
      this.queryAll()
      
    },
    },
    mounted(){
      this.queryAll()
    }
  }
</script>

<style lang="scss" scoped>

</style>